home *** CD-ROM | disk | FTP | other *** search
/ Total Web Page (Professional Suite) / Total Web Page 99.iso / CGI / DOWNLOAD.CGI-S=RAND_LINK&C=TXT&F=RAND_LINK.PL < prev    next >
Perl Script  |  1996-06-03  |  2KB  |  51 lines

  1. #! /usr/local/bin/perl
  2. ##############################################################################
  3. # Random Link                   Version 1.0                                  #
  4. # Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
  5. # Created 7/15/95               Last Modified 7/30/95                        #
  6. # Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
  7. ##############################################################################
  8. # COPYRIGHT NOTICE                                                           #
  9. # Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
  10. #                                                                            #
  11. # Random Link may be used and modified free of charge by anyone so long as   #
  12. # this copyright notice and the comments above remain intact.  By using this #
  13. # code you agree to indemnify Matthew M. Wright from any liability that      #
  14. # might arise from it's use.                                                 #
  15. #                                                                            #
  16. # Selling the code for this program without prior written consent is         #
  17. # expressly forbidden.  In other words, please ask first before you try and  #
  18. # make money off of my program.                                              #
  19. #                                                                            #
  20. # Obtain permission before redistributing this software over the Internet or #
  21. # in any other medium.  In all cases copyright and header must remain intact.#
  22. ##############################################################################
  23. # Define Variables
  24.  
  25. $linkfile = "/home/mattw/public_html/links/database";
  26.  
  27. # Options
  28. $uselog = 1;            # 1 = YES; 0 = NO
  29.    $logfile = "/home/mattw/public_html/links/rand_log";
  30.  
  31. $date = `date +"%D"`; chop($date);
  32.  
  33. # Done
  34. ##############################################################################
  35.  
  36. open (LINKS, "$linkfile");
  37.  
  38. srand();                        # kick rand
  39. $nlines=@file=<LINKS>;          # inhale file & get # of lines
  40. print "Location: $file[int rand $nlines]\n\n";  # print a random line
  41.  
  42. close (LINKS);
  43.  
  44. if ($uselog eq '1') {
  45.    open (LOG, ">>$logfile");
  46.    print LOG "$ENV{'REMOTE_HOST'} - [$date]\n";
  47.    close (LOG);
  48. }
  49.  
  50. exit;
  51.